使用百度智能进行人体检测
public static string body_attr(string Token, string base64)
{
StringBuilder sb = new StringBuilder();
try
{
string token = Token;
string host = "https://aip.baidubce.com/rest/2.0/image-classify/v1/body_attr?access_token=" token;
Encoding encoding = Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host);
request.Method = "post";
request.KeepAlive = true;
// 图片的base64编码
String str = "image=" HttpUtility.UrlEncode(base64);
byte[] buffer = encoding.GetBytes(str);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string result = reader.ReadToEnd();
sb.Append("人体检测和属性识别:" "\r\n");
sb.Append(result "\r\n");
}
catch { }
return sb.ToString();
}
评论